import time

def sort(lst):
    for j in range(len(lst)-1):
        swap = False
        for i in range(0, len(lst)-1-j):
            # print (lst[i], lst[i+1])
            if lst[i] > lst[i+1]:
                lst[i], lst[i+1] = lst[i+1], lst[i]
                swap = True
        if swap == False:
            break


def read_file(file_name):
    f = open (file_name, 'r')
    sp = list(map(int, f.readlines()))
    f.close()
    return sp

spisok = read_file("m1_sorted.txt")
t1 = time.time()
sort(spisok)
t2 = time.time()
dt = int((t2 - t1) * 1000)
print (f'm1_sorted {dt} milliseconds')



spisok2 = read_file("m2_reverse.txt")
t1 = time.time()
sort(spisok2)
t2 = time.time()
dt = int((t2 - t1) * 1000)
print (f'm2_reverse {dt} milliseconds')



spisok3 = read_file("m3_shuffle.txt")
t1 = time.time()
sort(spisok3)
t2 = time.time()
dt = int((t2 - t1) * 1000)
print (f'm3_shuffle {dt} milliseconds')

